package com.tanhua.server.controller;

import cn.hutool.core.collection.CollUtil;
import com.tanhua.dubbo.pojo.Questionnaire;
import com.tanhua.server.service.SoulTestService;
import com.tanhua.server.vo.Answers;
import com.tanhua.server.vo.AnswersList;
import com.tanhua.server.vo.QuestionnaireVo;
import com.tanhua.server.vo.ReportVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;



@RestController
@RequestMapping("/testSoul")
public class SoulController {

    @Autowired
    private SoulTestService soulTestService;

    @GetMapping
    public List<QuestionnaireVo> queryQuestionList(){
        List<QuestionnaireVo> questionnaireVos = this.soulTestService.queryQuestionnaireList();
        return questionnaireVos;
    }

    @PostMapping
    public String answers(@RequestBody AnswersList answers){
        return this.soulTestService.answers(answers).toString();
    }

    @GetMapping("/report/{id}")
    public ReportVo getReport(@PathVariable("id")Long reportId){
        return (ReportVo) this.soulTestService.getReport(reportId);
    }
}
